﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["login"] == "ok")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "loginOk", "loginOk();", true);
            }
            else
            {
                string path = HttpContext.Current.Request.Url.AbsolutePath;
                string homepage = "/UBOX/UboxWeb/index.aspx";
                string readerpage = "/UBOX/UboxWeb/ReadPage.aspx";
                string googlepage = "/UBOX/UboxWeb/GoogleMap.aspx";
                if (path.Contains(homepage) || path.Contains(readerpage) || path.Contains(googlepage))
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "loginOff", "loginOff();", true);
                }
                else
                {
                    Response.Redirect(homepage);
                }
            } 
        }
    }
}
